<template>
    <div>
    <Table  
     :tableData="tableData"
     :tableLabel="tableLabel"
     :total='total'
     :currentPage='queryinfo.pagenum'
     :pageSize='queryinfo.pagesize'
       @handleSizeChange='handleSizeChange'
       @handleCurrentChange='handleCurrentChange'
    ></Table>
    </div>
   
</template>

<script setup>
import Table from '../components/commen/Table.vue'
import {Goods} from '../api/api'
import{ref,reactive} from 'vue'

const goodsList =ref()
const tableData=ref([])
const queryinfo= reactive({
    query :'',
    pagenum:1,
    pagesize:10
})
const total=ref()
const tableLabel=reactive([
    {
     label:'名称',
     prop:'goods_name'
    },
     {
     label:'价格(元)',
     prop:'goods_price'
    },
    
     {
     label:'重量(g)',
     prop:'goods_weight'
    },
    
     {
     label:'日期',
     prop:'add_time'
    },
  
    {
    label: "操作",type:'opt',
    operation:[{label:'编辑',icon:'Edit',type:'primary',methed:'edit'},
    {label:'删除',icon:'Delete',type:'danger',methed:'delete'},
   
    ] },

   
    
])
const getgoodsList = async() =>{
   
    const res=await Goods(queryinfo)
    console.log(res)
     tableData.value = res.data.data.goods;
     total.value=res.data.data.total
     console.log(tableData.value);
}
const handleSizeChange = (val) => {
     queryinfo.pagesize=val
     console.log('父子间',val)
     getgoodsList()
}
const handleCurrentChange = (val) => {
    queryinfo.pagenum=val
     console.log('父子间',val)
    getgoodsList()
}

getgoodsList()
</script>

<style lang="scss" scoped>

</style>